import { getGangItemListAPI } from "../../api/gang";
import { ref, onMounted, watch } from 'vue'

export default function useTable(filters: any) {
    const tableData = ref([]);
    const loading = ref(false);
    const totalCount = ref(0);

    // 请求数据
    const query = () => {
        loading.value = true;
        getGangItemListAPI({ ...filters }).then((res: any) => {
            tableData.value = res.data
            totalCount.value = res.totalCount
            loading.value = false;
        });
    };

    onMounted(() => {
        query();
    })
    watch(filters, query)

    return {
        tableData,
        loading,
        totalCount,
        query
    }
}